package com.itboye.ihomebank.presenter;

import java.util.Observer;

import com.itboye.ihomebank.base.BasePresenter;
import com.itboye.ihomebank.base.ICompleteListener;
import com.itboye.ihomebank.bean.HouseBean;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.interfaces.KeyInterface;
import com.itboye.ihomebank.responsitory.KeyRepository;

public class KeyPresenter extends BasePresenter implements KeyInterface<HouseBean>{

	public KeyPresenter(Observer observer) {
		super(observer);
	}
	
	// 注册
	public static final String register_success = UserPresenter.class.getName()
				+ "_Rregister_success";// 由此判断请求的接口
	public static final String register_fail = UserPresenter.class.getName()
				+ "_Register_fail";

	/**
	 * 注册
	 */
	@Override
	public void getRegister(String uid) {
		KeyInterface<HouseBean> user = new KeyRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(register_success);
						KeyPresenter.this.setChanged();
						KeyPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(register_fail);
						KeyPresenter.this.setChanged();
						KeyPresenter.this.notifyObservers(result);

					}
				});
		user.getRegister(uid);
	}

}
